#pragma once
#include "PAKWriter.h"
#include "DeclarationManager.h"

namespace ds {

struct BMFontDefinition {
	std::string name;
	std::string texture;
	uint32 startChar;
	uint32 endChar;
	uint32 charHeight;
	uint32 startX;
	uint32 startY;
	uint32 texWidth;
	uint32 texHeight;
	uint32 padding;
};

class FontDecl : public ResourceDeclaration {

public:
	FontDecl(const std::string& name) : ResourceDeclaration(name) , m_Name(name) {}
	virtual ~FontDecl() {}
	void parseCategory(Category* category) {}
	DeclarationType getType() const {
		return DT_FONT;
	}	
	std::string& getName() {
		return m_Name;
	}
	BMFontDefinition& getFontDefinition() {
		return m_Definition;
	}
	void setTexture(const std::string& texture) {
		m_Definition.texture = texture;
	}
	void setPadding(int padding) {
		m_Definition.padding = padding;
	}
	void setStartChar(int startChar) {
		m_Definition.startChar = startChar;
	}
	void setEndChar(int endChar) {
		m_Definition.endChar = endChar;
	}
	void setHeight(int height) {
		m_Definition.charHeight = height;
	}
	void setStartX(int startX) {
		m_Definition.startX = startX;
	}
	void setStartY(int startY) {
		m_Definition.startY = startY;
	}
	void setTexWidth(int width) {
		m_Definition.texWidth = width;
	}
	void setTexHeight(int height) {
		m_Definition.texHeight = height;
	}
private:
	std::string m_Name;
	BMFontDefinition m_Definition;
};

class FontParser : public DeclarationParser {

public:
	FontParser() {}
	virtual ~FontParser() {}
	ResourceDeclaration* loadTextFile(const ResourceFile& resourceFile) {
		return 0;
	}
	void loadTextFile(const ResourceFile& resourceFile,DeclarationManager* declarationManager);
	void createResource(ResourceDeclaration* declaration);
	DeclarationType getType() const {
		return DT_FONT;
	}
	bool isSupported(const std::string& fileEnding) const;
	bool isReloadable() const {
		return false;
	}	

private:
	ResourceDeclaration* parseCategory(Category* category);
	bool isFillColor(const Color& col);
};

}
